package com.zlp.mall.portal.security.config;

import com.zlp.mall.portal.modules.ums.service.MemberService;
import com.zlp.mall.security.config.SecurityConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
import javax.annotation.Resource;


@Configuration
@EnableWebSecurity  // 启动
public class PortalSecurityConfig extends SecurityConfig {

    @Resource
    private MemberService memberService;

    /**
     * 认证交给springsecurity
     * @return
     */
    @Bean
    public UserDetailsService userDetailsService(){

        return username -> memberService.loadMemberByUsername(username);
    }

}
